package org.zuel.boot.demo.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import org.zuel.boot.demo.param.BatchAuthParam;
import org.zuel.boot.demo.service.IAuthService;

@RestController
@RequestMapping(value ="/auth")
public class AuthController {
    private final IAuthService authService;

    @Autowired
    public AuthController(IAuthService authService) {
        this.authService = authService;
    }

    @GetMapping(value = "/user_role/list")
    public Object userRoleList(@RequestParam(value = "userId", required = false) Integer userId,
                               @RequestParam(value = "roleId", required = false) Integer roleId) {
        return authService.userRoleList(userId, roleId);
    }

    @PostMapping(value = "/user_role/batch")
    public Object batchAuthRole(@RequestBody BatchAuthParam param) {
        return authService.batchAuthRole(param);
    }

    @GetMapping(value = "/role_perm/list")
    public Object rolePermList(@RequestParam(value = "roleId", required = false) Integer roleId,
                               @RequestParam(value = "permId", required = false) Integer permId) {
        return authService.rolePermList(roleId, permId);
    }

    @PostMapping(value = "/role_perm/batch")
    public Object batchAuthPerm(@RequestBody BatchAuthParam param) {
        return authService.batchAuthPerm(param);
    }

    @GetMapping(value = "/role_perm/vos")
    public Object rolePermVoList(@RequestParam(value = "roleId", required = false) Integer roleId,
                                 @RequestParam(value = "permId", required = false) Integer permId) {
        return authService.rolePermVoList(roleId, permId);
    }
}
